import store from "./store";

export default function(){
    return new Promise((res,rej)=>{
        let token = localStorage.getItem('token')

        let tokenExpired = localStorage.getItem('tokenExpired')
        if(token){
            let now = Date.now();
            if(now >= tokenExpired){
                localStorage.clear()  // 过期了
                res()

            }else{
                store.dispatch('getUserInfo',token)
                .then(res=>{
                    res()
                })
            }
        }else{
            res()
        }
    })
}